#!/bin/sh

#TO GROUP DIRS TO BE RECALLED

for i in `cat lists/problem.grep.Ns`; do echo $i | perl -ne ' chomp; /^.*\/processed\/(P\dK-\d{5})\.([FR])\.fasta/; print "$1 $2\n" '>> recall.dirsToRecall ; done;

/bioinfo/soft/packages/cmhtools/smp-runner --quiet --smp=16 --command="find ./ -type d -name \"*<1>*\" | grep \"\-<2>\" "  < recall.dirsToRecall | sort >> recall.fullDirsToRecall

for i in `cat recall.fullDirsToRecall` ; do find $i -name "*.ab1" ; done >> recall.fullFilesToRecall

mkdir ./filesToRecall

for i in `cat recall.fullDirsToRecall` ; do mkdir ./filesToRecall/`basename $i` ; done

perl -ne ' chomp; /^.*\/(P\dK-\d{5}-[RF].*)\//; print "$_ ./filesToRecall/$1\n"; ' < recall.fullFilesToRecall > recall.fullFilesToRecallWithDir

/bioinfo/soft/packages/cmhtools/smp-runner --quiet --smp=128 --command="cp -af <1> <2>" < recall.fullFilesToRecallWithDir

tar cf filesToRecall-`basename \`pwd\``.tar filesToRecall/

